//
//  ZYSouSuoViewController.m
//  XiangMuYiBai
//
//  Created by mac on 15-4-20.
//  Copyright (c) 2015年 zhiyou. All rights reserved.
//

#import "ZYSouSuoViewController.h"
#import "Header.h"
@interface ZYSouSuoViewController ()

@end

@implementation ZYSouSuoViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    UIImageView *touTiao=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
    touTiao.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
    [self.view addSubview:touTiao];
    UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
    label.text=@"搜索";
    label.font=[UIFont systemFontOfSize:30];
    label.textColor=[UIColor whiteColor];
    label.textAlignment=NSTextAlignmentCenter;
    [self.view addSubview:label];
    
    UIButton *back=[UIButton buttonWithType:UIButtonTypeSystem];
    back.frame=CGRectMake(20, 20, 20, 20);
    [back setBackgroundImage:[UIImage imageNamed:@"back@2x.png"] forState:UIControlStateNormal];
    [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:back];
    UIScrollView *scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 60, 320, 30)];
    scrollView.contentSize=CGSizeMake(80*10, 30);
    scrollView.contentOffset=CGPointMake(0, 0);
    scrollView.pagingEnabled=YES;
    scrollView.backgroundColor=[UIColor lightGrayColor];
    scrollView.showsHorizontalScrollIndicator=NO;
    [self.view addSubview:scrollView];
    labelTiao=[[UILabel alloc]init];
    labelTiao.center=CGPointMake(40, 29);
    labelTiao.bounds=CGRectMake(0, 0, 30, 2);
    labelTiao.backgroundColor=[UIColor redColor];
    [scrollView addSubview:labelTiao];
    NSArray *array=@[@"百度",@"谷歌",@"智游集团",@"水费",@"电费",@"电话费",@"公交站点",@"候车",@"公积分",@"社保"];
    for (int i=0; i<10; i++)
    {
        NSString *str=[array objectAtIndex:i];
        UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
        [btn setTitle:str forState:UIControlStateNormal];
        btn.frame=CGRectMake(80*i, 0, 80, 28);
        btn.tag=i+1;
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
        [scrollView addSubview:btn];
    }
        UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 90, 320, 390)];
   NSString* str=[NSString stringWithFormat:@"http://www.baidu.com"];
    NSURL *url=[NSURL URLWithString:str];
    NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
    [webView loadRequest:request];
    [self.view addSubview:webView];
    
}
-(void)click:(UIButton *)button
{
    int a=button.tag;
    buttonTag =a;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationRepeatCount:1];
    labelTiao.center=CGPointMake(40+80*(button.tag-1), 29);
    if (a==3 || a==7)
    {
        labelTiao.bounds=CGRectMake(0, 0, 4*15, 2);
    }
    else if (a==6 || a==9)
    {
        labelTiao.bounds=CGRectMake(0, 0, 3*15, 2);
    }
    else
    {
         labelTiao.bounds=CGRectMake(0, 0, 2*15, 2);
    }
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(zhuanHuan)];
    [UIView commitAnimations];
}
-(void)zhuanHuan
{
    int a = buttonTag;
    UIWebView *webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 90, 320, 390)];
    NSString *str;
    switch (a) {
        case 1:
        {
        str=[NSString stringWithFormat:@"http://wap.baidu.com"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 2:
        {
            str=[NSString stringWithFormat:@"http://www.google.com.hk"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 3:
        {
            str=[NSString stringWithFormat:@"http://wap.zhiyou100.com/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 4:
        {
            str=[NSString stringWithFormat:@"http://wap.waterol.cn/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 5:
        {
            str=[NSString stringWithFormat:@"http://wap.zzcha.net/dianfei/zhengzhou/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 6:
        {
            str=[NSString stringWithFormat:@"http://wap.10010.com/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 7:
        {
            str=[NSString stringWithFormat:@"http://wap.jsyongye.com/A/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 8:
        {
            str=[NSString stringWithFormat:@"http://wap.jsyongye.com/A/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 9:
        {
            str=[NSString stringWithFormat:@"http://zz.bendibao.com/live/zzgjj/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
        case 10:
        {
            str=[NSString stringWithFormat:@"http://wap.zzsi.com/"];
            NSURL *url=[NSURL URLWithString:str];
            NSURLRequest *request=[[NSURLRequest alloc]initWithURL:url];
            [webView loadRequest:request];
            [self.view addSubview:webView];
        }
            break;
            
        default:
            break;
    }
    //str=[NSString stringWithFormat:@"http://www.baidu.com"];

}
-(void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
